package com.example.client_anna.network.room.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.client_anna.network.room.dao.GoodsDao;
import com.example.client_anna.network.room.entity.Goods;

/**
 * @author cy
 * @email 272884043@qq.com
 * @date 2021/10/19
 */
@Database(entities = {Goods.class},version = 1)
public abstract class ClientDataBase extends RoomDatabase {

    private static final String DATABASE_NAME = "client_db";

    private static ClientDataBase dataBase;

    public static synchronized ClientDataBase getDataBase(Context context){
        if(dataBase == null){
            dataBase = Room.databaseBuilder(context.getApplicationContext(),ClientDataBase.class,DATABASE_NAME).build();
        }
        return dataBase;
    }
    public abstract GoodsDao getGoodsDao();
}
